Element.Methods.r31n = function(elm, imgs){
    elm.elmImg = new Element('img',{ src: elm.checked?imgs.checked:imgs.unchecked });
    if(elm.type == 'checkbox'){
        elm.elmImg.observe('click',function(){
            elm.checked = !elm.checked;
            elm.elmImg.src = elm.checked?imgs.checked:imgs.unchecked;
        });
        elm.observe('change',function(){
            elm.elmImg.src = elm.checked?imgs.checked:imgs.unchecked;
        });
    }
    else if(elm.type == 'radio'){
        elm.elmImg.observe('click',function(){
            if(!elm.checked){
                $$('input[type=radio][name="'+elm.name+'"]').each(function(e){
                    e.checked = false;
                      e.elmImg.src = imgs.unchecked;
                });
                elm.checked = true;
                elm.elmImg.src = imgs.checked
            }
        });
        elm.observe('change',function(){
            if(elm.checked){
                elm.elmImg.src = imgs.checked;
                $$('input[type=radio][name="'+elm.name+'"]').without(elm).each(function(e){
                    e.checked = false;
                    e.elmImg.src = imgs.unchecked;
                });
            }
        });
    }
    if(imgs.hover){
        elm.elmImg.observe('mouseover',function(){
            elm.elmImg.src = imgs.hover;
        });
        elm.elmImg.observe('mouseout',function(){
            elm.elmImg.src = elm.checked?imgs.checked:imgs.unchecked;
        });
        $$('label[for='+elm.id+']').each(function(e){
            e.observe('mouseover',function(){
            elm.elmImg.src = imgs.hover;
            });
            e.observe('mouseout',function(){
            elm.elmImg.src = elm.checked?imgs.checked:imgs.unchecked;
            });
            e.addClassName('r31n');
        });
    }
    elm.addClassName('r31n').hide().insert({after: elm.elmImg.addClassName('r31n')});
    return elm;
}

Element.addMethods();